package com.leenleda.ips.util;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.Gravity;
import android.widget.TextView;
import android.widget.Toast;

import com.leenleda.ips.MyApplication;
import com.leenleda.ips.R;

public class UToast {


    private static Toast mToast;

    public static void showToast(String pMsg) {
        if (pMsg == null)
            return;
        if (TextUtils.isEmpty(pMsg.trim()))
            return;
        showShortToast(MyApplication.getInstance(), pMsg);
    }

    private static void showShortToast(Context context, String text) {
        if (mToast == null) {
            mToast = Toast.makeText(context.getApplicationContext(), text, Toast.LENGTH_SHORT);
            mToast.setGravity(Gravity.CENTER, 0, 0);
//            mToast.getView().setBackgroundColor(context.getResources().getColor(R.color.black));
//            TextView textV = (TextView) mToast.getView().findViewById(android.R.id.message);
//            textV.setTextColor(Color.WHITE);
//            textV.setTextSize(16);
        } else {
            mToast.setText(text);
            mToast.setDuration(Toast.LENGTH_SHORT);
        }
        mToast.show();
    }
}
